<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <#include "/pubHeadStyle.html">
</head>
<body>
<link href="${ctx}/css/workflow.css" rel="stylesheet">
<title>流程设置</title>
<div class="layui-btn-container" style="margin: 10px;">
    <a class="layui-btn layui-btn-sm" lay-event="downloadImage" id="bpmnImage">
        <i class="layui-icon layui-icon-picture-fine"></i>
        <span>流程图</span>
    </a>
    <a class="layui-btn layui-btn-sm" lay-event="downloadXml" id="bpmnXml">
        <i class="layui-icon layui-icon-download-circle"></i>
        <span>BPMN-XML</span>
    </a>
    <#if modelIdForReturn?? >
        <a class="layui-btn layui-btn-sm" id="returnIsMainUrl">
    <#else>
        <a class="layui-btn layui-btn-sm" id="returnUrl">
    </#if>
        <i class="layui-icon layui-icon-return"></i>
        <span>返回</span>
    </a>
</div>
<div class="layui-tab layui-tab-brief" lay-filter="commonSetting">
    <ul class="layui-tab-title">
     <#--element设置默认跳转，==true : 跳转明细模块；==false: 跳转历史模块-->
     <#--2019-12-24 新增逻辑：历史版本返回主版本时设置element默认为历史模块-->
        <#if !isHistory??>
            <li class="layui-this" lay-id="detail">明细</li>
        <#else>
            <li lay-id="detail">明细</li>
        </#if>
        <li lay-id="nodeSummary">节点概要</li>
        <li lay-id="nodeSet">节点设置</li>
        <li lay-id="userSet">人员</li>
        <li lay-id="formSet">表单</li>
        <li lay-id="nodeBtnSet">操作按钮</li>
        <li lay-id="varSet">变量管理</li>
        <!--<li lay-id="gangedSet">联动</li>-->
        <li lay-id="instances">流程实例</li>
    <#--element设置默认跳转，==true : 跳转明细模块；==false: 跳转历史模块-->
    <#--2019-12-24 新增逻辑：历史版本返回主版本时设置element默认为历史模块-->
        <#if !isHistory??>
            <li lay-id="history">历史</li>
        <#else>
            <li class="layui-this" lay-id="history">历史</li>
        </#if>
        <li lay-id="otherParams">其他参数</li>
    </ul>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <div id="settingDiv" style="overflow-y: auto;"></div>
        </div>
    </div>
</div>

<input type="hidden" id="modelId" value="${modelId!}">
<input type="hidden" id="modelIdre" value="${modelIdForReturn!}">
<input type="hidden" id="parentProcDefId" value="${parentProcDefId!}">
<script>
    layui.config({
        base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index','jquery','setter','element'],function () {
        var setter=layui.setter;
        var $ = layui.jquery;
        var element = layui.element;
        var modelId = "${modelId}";
        var parentProcDefId = "${parentProcDefId!}";

        var detailUrl      = "${ctx}/workflow/actDefModel/view/detail?modelId="+modelId;
        var nodeSummaryUrl = "${ctx}/workflow/actDefModel/view/nodeSummary?modelId="+modelId + "&parentProcDefId=" + parentProcDefId;
        var nodeSetUrl     = "${ctx}/workflow/actDefModel/view/nodeSet?modelId="+modelId + "&parentProcDefId=" + parentProcDefId;
        var userSetUrl     = "${ctx}/workflow/actDefModel/view/userSet?modelId="+modelId + "&parentProcDefId=" + parentProcDefId;
        var formSetUrl     = "${ctx}/workflow/bpmNodeSet/view/list?modelId="+modelId + "&parentProcDefId=" + parentProcDefId;
        var nodeBtnSetUrl  = "${ctx}/workflow/bpmNodeButton/view/list?modelId="+modelId;
        var varSetUrl      = "${ctx}/workflow/bpmDefVar/view/list?modelId="+modelId;
        var gangedSetUrl   = "${ctx}/workflow/bpmGangedSet/view/list?modelId="+modelId + "&parentProcDefId=" + parentProcDefId;
        var historyUrl     = "${ctx}/workflow/actDefModel/view/history?modelId="+modelId +"&modelIdForReturn=${modelIdForReturn}";
        var instancesUrl   = "${ctx}/workflow/actDefModel/view/instances?modelId="+modelId + "&parentProcDefId=" + parentProcDefId;
        var otherParamsUrl = "${ctx}/workflow/actDefModel/view/otherParam?modelId="+modelId + "&parentProcDefId=" + parentProcDefId;
        function changeLoad(url){
            $("#settingDiv").height($("body.layui-layout-body").height()-120)
            $("#settingDiv").load(url);
        }
        //全局使用。即所有弹出层都默认采用，但是单个配置skin的优先级更高
        layer.config({
            skin: 'btn-class'
        })

        //主版本时启用，用户返回流程定义管理页面
        $('#returnUrl').attr("href",serverPath.workflowPath + setter.workflowLinkPath+"actDefModel/view/list");
        //历史版本时启用，用于返回主版本的流程定义设置页面
        $('#returnIsMainUrl').click(function(){
            $(this).attr("href",serverPath.workflowPath + setter.workflowLinkPath + "actDefModel/view/commonSetting?modelId=${modelIdForReturn}&isHistory=true");
        });

        $("dl.layui-nav-child dd[data-name=流程定义管理]").addClass("layui-this");
        $('#bpmnImage').click(function (){
            layer.open({
                type: 2,
                title: "流程图",
                area: ['50%', '60%'],
                btn:['关闭'],
                skin: 'btn-close',
                content: serverPath.workflowPath + setter.workflowLinkPath + 'bpmnImage/view/diagram?modelId=' + modelId
            });
        });

        $('#bpmnXml').click(function (){
            layer.open({
                type: 2,
                title: "流程xml文件",
                shade: 0.3,
                offset: ['130px', '300px'],
                left: 200,
                area: ['50%', '80%'],
                btn:['关闭'],
                skin: 'btn-close',
                content: serverPath.workflowPath + setter.workflowLinkPath + 'bpmnXml/bpmn20?modelId=' + modelId
            });
        });
        /**
         * element设置默认跳转
         *  ==true : 跳转明细模块
         *  ==false: 跳转历史模块
         * 2019-12-24 新增逻辑：历史版本返回主版本时设置element默认为历史模块
         */
        <#if !isHistory??>
            changeLoad(detailUrl);
        <#else>
            changeLoad(historyUrl);
        </#if>
        element.on('tab(commonSetting)', function(){
            var layId = this.getAttribute('lay-id');
            switch (layId){
                case "detail":
                    changeLoad(detailUrl);
                    $(".qtip").hide();
                    break;
                case "nodeSummary":
                    changeLoad(nodeSummaryUrl);
                    $(".qtip").hide();
                    break;
                case "nodeSet":
                    changeLoad(nodeSetUrl);
                    break;
                case "userSet":
                    changeLoad(userSetUrl);
                    $(".qtip").hide();
                    break;
                case "nodeBtnSet":
                    changeLoad(nodeBtnSetUrl);
                    $(".qtip").hide();
                    break;
                case "varSet":
                    changeLoad(varSetUrl);
                    $(".qtip").hide();
                    break;
                case"gangedSet":
                    changeLoad(gangedSetUrl);
                    $(".qtip").hide();
                    break;
                case "formSet":
                    changeLoad(formSetUrl);
                    $(".qtip").hide();
                    break;
                case "history":
                    changeLoad(historyUrl);
                    $(".qtip").hide();
                    break;
                case "instances":
                    changeLoad(instancesUrl);
                    $(".qtip").hide();
                    break;
                case "otherParams":
                    changeLoad(otherParamsUrl);
                    $(".qtip").hide();
                    break;

            }
        });
    });
   /* var rId =  sessionStorage.getItem("returnId");
    if("${isHistory}" && rId!=null) {
        //跳转至历史模块
        var element = layui.element;
        element.tabChange("commonSetting","history");
        sessionStorage.removeItem("returnId");
    };*/
</script>
</body>
</html>